package com.bookmarket.test;
/*
*
* 测试后台增删改查
*
* */
import com.bookmarket.entity.Btype;
import com.bookmarket.entity.Stype;
import com.bookmarket.service.IClassifyService;
import com.github.pagehelper.PageHelper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import javax.annotation.Resource;
import java.util.List;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:spring-mybatis.xml")
public class ClassifyDemo {


        @Resource
        private IClassifyService iClassifyService;
    /*************************************************************************/
        @Test//大类型增
        public void test(){
            Btype b=new Btype("电子书");
            iClassifyService.insertBtype(b);
        }
        @Test//大类型删
        public void test1(){
            iClassifyService.delBtype(13);
        }
        @Test//大类型改
        public void test2(){
            Btype b=new Btype(14,"港台图书");
            iClassifyService.updateBtype(b);
        }
        @Test//大类型查(查看所有)
        public void test3(){
            List<Btype> list=iClassifyService.selectBtype();
            for (Btype b:list){
                System.out.println(b.getId()+","+b.getType());
            }
        }
        //测试查询对应所有
        @Test
        public void test8(){
            //定义页码页数
            PageHelper.startPage(2, 5);
            //根据页码页数查询所有
            List<Btype> list = iClassifyService.selectBtype();
            //遍历结果集
            for (Btype u : list) {
                System.out.println(u.getType());
            }
        }
        @Test//测试分页
        public void test9(){
            Btype b=new Btype(14,"港台图书");
            System.out.println(iClassifyService.queryB(2,2,b));
        }
    /*************************************************************************/
       @Test//小类型增
        public void test4(){
            Btype btype=new Btype(12);
            Stype stype=new Stype("末日",btype);
            iClassifyService.insertStype(stype);
        }
        @Test//小类型删
        public void test5(){
            iClassifyService.delStype(21);
        }
        @Test//小类型改
        public void test6(){
            Btype btype=new Btype(1);
            Stype stype=new Stype(22,"异能",btype);
            iClassifyService.updateStype(stype);
        }
        @Test//小类型查
        public void test7(){
            List list=iClassifyService.selectStype();
            System.out.println(list);
        }


    public IClassifyService getiClassifyService() {
        return iClassifyService;
    }

    public void setiClassifyService(IClassifyService iClassifyService) {
        this.iClassifyService = iClassifyService;
    }
}
